#include "StdAfx.h"
#include "NamedDisposableObjectBase.h"

using namespace Adaptive::Foundation;

/*--------------------------------------------------------------------------------
 * Constructor / Dispose / Destructor Methods
 *------------------------------------------------------------------------------*/
#pragma region Constructor / Dispose / Destructor Methods
// Initializes a new instance of the class.
NamedDisposableObjectBase::NamedDisposableObjectBase()
{
	_name = String::Empty;
	_disposed = false;
}
// Class destructor.
NamedDisposableObjectBase::~NamedDisposableObjectBase()
{
	if (!_disposed)
	{
		OnDisposing(EventArgs::Empty);
		_disposed = true;
	}
	_name = nullptr;
}
// Deallocates internally allocated objects.
void NamedDisposableObjectBase::!NamedDisposableObjectBase()
{
	_disposed = true;
}
#pragma endregion

/*--------------------------------------------------------------------------------
 * Public Properties
 *------------------------------------------------------------------------------*/
#pragma region Public Properties
// Gets a value indicating whether the object has been disposed.
bool NamedDisposableObjectBase::Disposed::get()
{
    return _disposed;
}
// Gets a value indicating whether the object has been disposed.
String^ NamedDisposableObjectBase::Name::get()
{
	return _name;
}
void NamedDisposableObjectBase::Name::set(String^ value)
{
	if (value != _name)
	{
		_name = value;
		OnNameChanged(EventArgs::Empty);
	}
}
#pragma endregion

/*--------------------------------------------------------------------------------
 * Protected Methods / Event Methods
 *------------------------------------------------------------------------------*/
#pragma region Protected Methods / Event Methods
// Raises the <see cref="Disposing"/> event.
void NamedDisposableObjectBase::OnDisposing(EventArgs^ e)
{
	Disposing(this, e);
}
// Raises the <see cref="OnNameChanged"/> event.
void NamedDisposableObjectBase::OnNameChanged(EventArgs^ e)
{
	NameChanged(this, e);
}
#pragma endregion
